package invaliddotnetbusinesscomponentdependency;

import org.eclipse.emf.ecore.EObject;

import org.eclipse.viatra2.emf.incquery.validation.runtime.Constraint;
import org.eclipse.viatra2.emf.incquery.validation.runtime.ValidationUtil;
import org.eclipse.viatra2.emf.incquery.runtime.api.impl.BaseGeneratedMatcherFactory;
import invaliddotnetbusinesscomponentdependency.InvalidDotNetBusinessComponentDependencyMatch;
import invaliddotnetbusinesscomponentdependency.InvalidDotNetBusinessComponentDependencyMatcherFactory;
import invaliddotnetbusinesscomponentdependency.InvalidDotNetBusinessComponentDependencyMatcher;

public class InvalidDotNetBusinessComponentDependencyConstraint extends Constraint<InvalidDotNetBusinessComponentDependencyMatch> {

	private InvalidDotNetBusinessComponentDependencyMatcherFactory matcherFactory;

	public InvalidDotNetBusinessComponentDependencyConstraint() {
		matcherFactory = new InvalidDotNetBusinessComponentDependencyMatcherFactory();
	}

	@Override
	public String getMessage() {
		return "$dotNetComponent.name$ .Net business component should not depend from $otherComponent.name$ business component, cause it is implemented with another technology!";
	}

	@Override
	public EObject getLocationObject(InvalidDotNetBusinessComponentDependencyMatch signature) {
		Object location = signature.get("dotNetComponent");
		if(location instanceof EObject){
			return (EObject) location;
		}
		return null;
	}
	
	@Override
	public int getSeverity() {
		return ValidationUtil.getSeverity("error");
	}
	
	@Override
	public BaseGeneratedMatcherFactory<InvalidDotNetBusinessComponentDependencyMatch, InvalidDotNetBusinessComponentDependencyMatcher> getMatcherFactory() {
		return matcherFactory;
	}
}
